//
//  LGCancerPatientBasicCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2024/7/19.
//  癌症 - 基本信息

#import "LGCancerPatientBasicCell.h"

@interface LGCancerPatientBasicCell() 
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *contentLabel;

@end

@implementation LGCancerPatientBasicCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setTitle:(NSString *)title{
    _title = title;
    self.titleLabel.text = title;
}

-(void)setContent:(NSString *)content{
    _content = content;
    self.contentLabel.text = (content.length>0)?content:@"--";
    CGFloat contentH = [self.contentLabel.text textHeightWithFont:LGFontWeight(16, UIFontWeightMedium) maxWidth:Screen_W-viewPix(171)];
    CGFloat titleH = [self.titleLabel.text textHeightWithFont:LGFont(15) maxWidth:viewPix(100)];
    CGFloat height = contentH>titleH?contentH:titleH;
    [self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(height));
    }];
    self.contentLabel.textAlignment = contentH>20?NSTextAlignmentLeft:NSTextAlignmentRight;
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    [self.baseView addSubview:self.titleLabel];
    [self.baseView addSubview:self.contentLabel];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.baseView).offset(viewPix(12));
        make.top.equalTo(self.contentLabel);
        make.width.equalTo(@(viewPix(100)));
    }];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.baseView).offset(viewPix(8));
        make.bottom.equalTo(self.baseView).offset(-viewPix(8));
        make.right.equalTo(self.baseView).offset(-viewPix(12));
        make.left.equalTo(self.titleLabel.mas_right).offset(viewPix(15));
        make.height.equalTo(@(20));
    }];
    
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#606266" textFont:LGFont(15) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _titleLabel;
}

-(UILabel *)contentLabel{
    if(!_contentLabel){
        _contentLabel = [UILabel lableWithText:@" " colorString:@"#282828" textFont:LGFontWeight(16, UIFontWeightMedium) textAlignment:NSTextAlignmentRight lines:0];
        _contentLabel.lineBreakMode = NSLineBreakByCharWrapping;
    }
    return _contentLabel;
}


@end
